package com.jcfy.project.module.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jcfy.framework.aspectj.lang.annotation.Log;
import com.jcfy.framework.aspectj.lang.enums.BusinessType;
import com.jcfy.project.module.domain.TTeam;
import com.jcfy.project.module.service.ITTeamService;
import com.jcfy.framework.web.controller.BaseController;
import com.jcfy.framework.web.domain.AjaxResult;
import com.jcfy.common.utils.poi.ExcelUtil;
import com.jcfy.framework.web.page.TableDataInfo;

/**
 * 团长(自提点)Controller
 *
 * @author jiangfeng
 * @date 2020-08-05
 */
@RestController
@RequestMapping("/module/team" )
public class TTeamController extends BaseController {
    @Autowired
    private ITTeamService tTeamService;

    /**
     * 查询团长(自提点)列表
     */
    @PreAuthorize("@ss.hasPermi('module:team:list')" )
    @GetMapping("/list" )
    public TableDataInfo list(TTeam tTeam) {
        startPage();
        List<TTeam> list = tTeamService.selectTTeamList(tTeam);
        return getDataTable(list);
    }

    /**
     * 导出团长(自提点)列表
     */
    @PreAuthorize("@ss.hasPermi('module:team:export')" )
    @Log(title = "团长(自提点)" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(TTeam tTeam) {
        List<TTeam> list = tTeamService.selectTTeamList(tTeam);
        ExcelUtil<TTeam> util = new ExcelUtil<TTeam>(TTeam. class);
        return util.exportExcel(list, "team" );
    }

    /**
     * 获取团长(自提点)详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:team:query')" )
    @GetMapping(value = "/{teamId}" )
    public AjaxResult getInfo(@PathVariable("teamId" ) Long teamId) {
        return AjaxResult.success(tTeamService.selectTTeamById(teamId));
    }

    /**
     * 新增团长(自提点)
     */
    @PreAuthorize("@ss.hasPermi('module:team:add')" )
    @Log(title = "团长(自提点)" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTeam tTeam) {
        return toAjax(tTeamService.insertTTeam(tTeam));
    }

    /**
     * 修改团长(自提点)
     */
    @PreAuthorize("@ss.hasPermi('module:team:edit')" )
    @Log(title = "团长(自提点)" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTeam tTeam) {
        return toAjax(tTeamService.updateTTeam(tTeam));
    }

    /**
     * 删除团长(自提点)
     */
    @PreAuthorize("@ss.hasPermi('module:team:remove')" )
    @Log(title = "团长(自提点)" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{teamIds}" )
    public AjaxResult remove(@PathVariable Long[] teamIds) {
        return toAjax(tTeamService.deleteTTeamByIds(teamIds));
    }
}
